package ${package}.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import yyy.ab.common.core.BaseEntity;

<#if isNotNullColumns??>
import javax.validation.constraints.*;
</#if>
<#if hasTimestamp>
import java.sql.Timestamp;
</#if>
<#if hasBigDecimal>
import java.math.BigDecimal;
</#if>
import java.util.Objects;

/**
* @author ${author}
* @date ${date}
*/
@Getter
@Setter
@TableName(value = "${tableName}")
public class ${className} extends BaseEntity<${pkColumnType}> {
<#if columns??>
    <#list columns as column>

    <#if column.columnKey = 'PRI'>
    <#if auto>
    @TableId(type = IdType.AUTO)
    <#else>
    @TableId(type = IdType.NONE)
    </#if>
    </#if>
    @TableField(value = "${column.columnName}")
    <#if column.istNotNull && column.columnKey != 'PRI'>
        <#if column.columnType = 'String'>
    @NotBlank
        <#else>
    @NotNull
        </#if>
    </#if>
    <#if (column.dateAnnotation)??>
    <#if column.dateAnnotation = 'CreationTimestamp'>
    @CreationTimestamp
    <#else>
    @UpdateTimestamp
    </#if>
    </#if>
    <#if column.remark != ''>
    @ApiModelProperty(value = "${column.remark}")
    <#else>
    @ApiModelProperty(value = "${column.changeColumnName}")
    </#if>
    private ${column.columnType} ${column.changeColumnName};
    </#list>
</#if>

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        ${className} ${changeClassName} = (${className}) o;
        return Objects.equals(id, ${changeClassName}.id);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id);
    }
}